/**
 *  Copyright (c) Filipe Manana <fdmanana@gmail.com>
 *  All rights reserved.
 * 
 *  This file is part of jsdet.
 *
 *  jsdet is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published
 *  by the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  jsdet is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with jsdet.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

package jsdet.arguments;


/**
 * 
 * @author Filipe Manana
 *
 */
public enum Option {

    HELP("-h", "--help", false),
    DEBUG(null, "--debug", false),
    SORT_CLASSES_ASC(null, "--asc", false),
    SORT_CLASSES_DESC(null, "--desc", false),
    NAMES_ONLY(null, "--names-only", false),
    SHOW_FUNCTIONS("-f", "--show-functions", false),
    SHOW_CLOSURE_OBJECTS("-o", "--show-closure-objects", false),
    SHOW_FILES(null, "--show-files", false),
    SHOW_INHERITED_MEMBERS("-i", "--show-inherited-members", false),
    ONLY_CLASSES("-c", "--classes", true),
    XML(null, "--xml", false),
    SIMPLE_HTML(null, "--html", false),
    HTML_GUI(null, "--html-gui", false);


    public static Option match(String name) {

        for (Option option : Option.values()) {
            if (option.hasShortName() && name.equals(option.getShortName())) {
                return option;
            }
            else if (option.hasLongName() && name.equals(option.getLongName())) {
                return option;
            }
        }

        return null;
    }


    private final String shortName;
    private final String longName;
    private final boolean hasValue;


    Option(String shortName, String longName, boolean hasValue) {
        this.shortName = shortName;
        this.longName = longName;
        this.hasValue = hasValue;
    }


    public boolean hasShortName() {
        return shortName != null && !shortName.isEmpty();
    }


    public boolean hasLongName() {
        return longName != null && !longName.isEmpty();
    }


    public boolean hasValue() {
        return hasValue;
    }


    public String getShortName() {
        return shortName;
    }


    public String getLongName() {
        return longName;
    }
}
